package io.renren.modules.mvs.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.mvs.dto.ViolationDto;
import io.renren.modules.mvs.entity.ViolationEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

import static io.renren.common.utils.Constant.UNPROCESSED;

/**
 * 违章记录表
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2025-03-30 17:08:24
 */
@Mapper
public interface MvsViolationDao extends BaseMapper<ViolationEntity> {

    IPage<ViolationDto> selectPageByCondition(Page<?> page, @Param("condition") Map<String, Object> condition);

    @Select("SELECT id FROM mvs_violation " +
            "WHERE user_id = 2 AND id NOT IN (SELECT violation_id FROM mvs_ticket) " +
            "AND violation_status = '" + UNPROCESSED + "'")
    List<Long> selectIdListByUserId(@Param("userId") Long userId);

    List<Map<String, ?>> selectCountByDateRange(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("userId") Long userId);

    ViolationDto selectDetailInfoById(Long id);
}
